//无缓存
/*const getVal = (steps, way) => {
	let counts = 0;
	if(steps == 0) {
		counts = 1;
	} else if(steps > 0) {
		for(let i in way) {
			counts += getVal(steps - way[i], way);
		}
	}
	return counts;
}
let c = getVal(4, [1, 2, 3]);*/
//缓存
const getVal = (steps, way, cache={}) => {
	if(cache[steps]){
		return cache[steps];
	}
	let counts = 0;
	if(steps == 0) {
		counts = 1;
	} else if(steps > 0) {
		for(let i in way) {
			counts += getVal(steps - way[i], way, cache);
			cache[steps] = counts;
		}
	}
	return counts;
}
let c = getVal(100, [1, 2, 3]);
console.log(c)














